package truedano.truedano;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;

public class MyCheckBox extends Activity {
	private CheckBox checkBox_Busiess;
	private CheckBox checkBox_Music;
	private CheckBox checkBox_Sports;
	private CheckBox checkBox_Anime;
	private CheckBox checkBox_TV;
	private CheckBox checkBox_Games;
	private CheckBox checkBox_Tech;
	private Button button_get_checkbox_value;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.my_check_box);
		setfindViewById();
		setListener();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.my_check_box, menu);
		return true;
	}
	
	private void setfindViewById(){
		checkBox_Busiess = (CheckBox) findViewById(R.id.checkBox_Busiess);
		checkBox_Music = (CheckBox) findViewById(R.id.checkBox_Music);
		checkBox_Sports = (CheckBox) findViewById(R.id.checkBox_Sports);
		checkBox_Anime = (CheckBox) findViewById(R.id.checkBox_Anime);
		checkBox_TV = (CheckBox) findViewById(R.id.checkBox_TV);
		checkBox_Games = (CheckBox) findViewById(R.id.checkBox_Games);
		checkBox_Tech = (CheckBox) findViewById(R.id.checkBox_Tech);
		button_get_checkbox_value = (Button) findViewById(R.id.button_get_checkbox_value);
	}
	
	private void setListener(){
		button_get_checkbox_value.setOnClickListener(new Button.OnClickListener(){
    		@Override
    		public void onClick(View v) {
    			String s="";
    			if(checkBox_Busiess.isChecked()){
    				s += checkBox_Busiess.getText()+",";
    			}
    			if(checkBox_Music.isChecked()){
    				s += checkBox_Music.getText()+",";
    			}
    			if(checkBox_Sports.isChecked()){
    				s += checkBox_Sports.getText()+",";
    			}
    			if(checkBox_Anime.isChecked()){
    				s += checkBox_Anime.getText()+",";
    			}
    			if(checkBox_TV.isChecked()){
    				s += checkBox_TV.getText()+",";
    			}
    			if(checkBox_Games.isChecked()){
    				s += checkBox_Games.getText()+",";
    			}
    			if(checkBox_Tech.isChecked()){
    				s += checkBox_Tech.getText()+",";
    			}
    			setTitle("You check : "+s);
    		}
        });
	}
}
